#include <iostream>
#include<vector>
using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    vector<long long> dp(n + 1);

    for (int i = 1; i <= n; i++)
        dp[i] += dp[i - 1] + a[i];
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }


}
